#!/bin/sh
#
pkgUpdates() {
	# updates=$(xbps-install -S -un | cut -d' ' -f2 | sort | uniq -c | xargs)
  updates=$(checkupdates 2>/dev/null | wc -l) # arch

	if [ -z "$updates" ]; then
		echo "Updated"
	else
		echo "$updates"" updates"
	fi
}

battery() {
	cat /sys/class/power_supply/BAT1/capacity
}

cpu() {
	grep -o "^[^ ]*" /proc/loadavg
}

disk() {
	df --output=pcent . | tail -n 1 | tr -d '[:space:]|%'
}

ram() {
	printf "%.0f\n" $(free -m | grep Mem | awk '{print ($3/$2)*100}')
}

backlight() {
	printf "%.0f\n" $(xbacklight -get)
}

wifi() {
	case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in
	up) printf "󰤨" ;;
	down) printf "󰤭" ;;
	esac
}

"$@"
